import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';

@Schema({ timestamps: true })
export class GenerationResult {
    @Prop({ type: Types.ObjectId, ref: 'WorkflowTemplate', required: true })
    templateId: Types.ObjectId;

    @Prop({ type: Types.ObjectId, ref: 'User', required: false })
    userId?: Types.ObjectId;

    @Prop({ required: true })
    imageUrl: string;

    @Prop({ type: Object, required: true })
    params: Record<string, any>;

    @Prop({ type: Object })
    metadata?: {
        promptId?: string;
        generationTime?: number;
        seed?: number;
    };
}

export type GenerationResultDocument = GenerationResult & Document;
export const GenerationResultSchema = SchemaFactory.createForClass(GenerationResult);